package com.ffyc.ssm.util;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *  自定义的String工具类
 */
public class StringUtil {

    /**
     * 截取文件扩展名
     * @param fileName
     * @return
     */
     public static String subFileType(String fileName){
         if(fileName!=null){
             return fileName.substring(fileName.lastIndexOf(".")+1);
         }
         return null;
     }

    public  static String newFileName(String oldFileName){
        Date date =new Date();
        SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyyMMddHHmmssSSS");
        return  simpleDateFormat.format(date)+"."+subFileType(oldFileName);
    }

    static SqlSessionFactory sqlSessionFactory =null;

    public static SqlSession getSession(){
        return sqlSessionFactory.openSession();
    }

    public static void main(String[] args) {
        Date date =new Date();
        SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyyMMddHHmmssSSS");
        System.out.println(simpleDateFormat.format(date));

    }

}

